/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.pc9.pswing.components.filebrowser;

import br.com.paulocanedo.pc9.laf.PLabelUI;
import java.awt.Component;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.UIManager;

/**
 *
 * @author paulocanedo
 */
class PFileListCellRenderer extends DefaultListCellRenderer {

    private PLabelUI lui = new PLabelUI();

    public PFileListCellRenderer() {
    }

    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        JLabel renderer = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        renderer.setUI(lui);

        if (isSelected) {
            setBackground(UIManager.getColor("List.selectionBackground"));
        }
        setIcon(((PFileView) value).getIcon(16));
        return renderer;
    }
}